﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace YourStore.Models
{
    public class topProduct
    {
        YourStoreEntities storeDB = new YourStoreEntities();
        public List<Product> GetTopSellingProduct(int count)
        {
            // Group the order details by Product and return
            // the Products with the highest count
            return storeDB.Products
                .OrderByDescending(a => a.OrderDetails.Count())
                .Take(count)
                .ToList();
        }
        public List<OrderDetail> GetTop(int count)
        {
            return storeDB.OrderDetails.OrderByDescending(a=>a.Order.OrderDate).Take(count).ToList();
        }
    }
}